<template>
    <div class="member-list">
        <div class="member-list-card">
            <div class="member-list-head">
                <Row :gutter="5" style="margin-bottom: 10px">
                    <!--<Col span="4">-->
                    <!--<DatePicker  clearable v-model="searchData.timeStartEnd" style="width: 100%" type="daterange" placeholder="时间筛选"></DatePicker>-->
                    <!--</Col>-->
                    <!--<Col span="4">-->
                    <!--<Input clearable v-model="searchData.loginName" placeholder="登录名" type="text"></Input>-->
                    <!--</Col>-->
                    <Col span="4">
                        <Input clearable v-model="searchData.username" placeholder="当前所有人编号" type="text"></Input>
                    </Col>
                    <!--<Col span="4">
                        <Input clearable v-model="searchData.old_username" placeholder="生成所有人编号" type="text"></Input>
                    </Col>-->
                    <Col span="4">
                        <Input clearable v-model="searchData.phone" placeholder="用户电话" type="text"></Input>
                    </Col>
                    <Col span="4">
                        <Input clearable v-model="searchData.num" placeholder="卡号" type="text"></Input>
                    </Col>

                    <!--</Row>-->
                    <!--<Row :gutter="5">-->
                    <!--<Col span="4">-->
                    <!--<Select clearable v-model="searchData.userType" placeholder="是否为店铺">-->
                    <!--<Option :value="1">是</Option>-->
                    <!--<Option :value="0">否</Option>-->
                    <!--</Select>-->
                    <!--</Col>-->
                    <!--<Col span="4">-->
                    <!--<Select clearable v-model="searchData.svip" placeholder="是否是金牌代理">-->
                    <!--<Option :value="1">是</Option>-->
                    <!--<Option :value="0">否</Option>-->
                    <!--</Select>-->
                    <!--</Col>-->
                    <!--<Col span="4">-->
                    <!--<Select clearable v-model="searchData.is_daili" placeholder="是否是为区代">-->
                    <!--<Option :value="1">是</Option>-->
                    <!--<Option :value="0">否</Option>-->
                    <!--</Select>-->
                    <!--</Col>-->
                    <Col span="30">
                        <ButtonGroup class="subSearch">
                            <!--<Button @click="$router.push({name:'member-add-nocache'})" type="primary" icon="plus-round">新增</Button>-->
                            <Button :loading="search_loading" @click="searchGetList" type="primary">
                                <Icon type="ios-pulse-strong"></Icon>
                                筛 选
                            </Button>
                        </ButtonGroup>
                    </Col>
                </Row>
            </div>
            <i-table height="645" stripe :columns="columns" :data="data"></i-table>
            <div style="padding: 15px;">
                <Page @on-page-size-change="changeTiao" @on-change="changePage" :current="index" :total="total"
                      show-elevator show-sizer :placement="'top'" :page-size="page_con"
                      :page-size-opts="[10, 15, 20, 30, 40, 50]"></Page>
            </div>
        </div>
        删除
        <Modal v-model="modal1" width="360">
            <p slot="header" style="color:#f60;text-align:center">
                <Icon type="information-circled"></Icon>
                <span>删除确认</span>
            </p>
            <div style="text-align:center">
                <p>是否继续删除？</p>
            </div>
            <div slot="footer">
                <Button type="error" size="large" long @click="del">删除</Button>
            </div>
        </Modal>
    </div>
</template>
<script>
    export default {
        name: "pointcard-list",
        data() {
            return {
                columns: [
                    {
                        title: '序号',
                        type: 'index',
                        width: 60,
                        align: "center",
                    },
                    // {
                    //     title: '登录名',
                    //     key: 'loginname',
                    //     align:"center",
                    // },
                    {
                        title: '持有人帐号',
                        key: 'username',
                        align: "center",
                    },
                    {
                        title: '卡号',
                        key: 'num',
                        align: "center",
                    },
                    // {
                    //     title: '可提余额',
                    //     key: 'money_shangcheng',
                    //     align:"center",
                    //     render:(h,params)=>{
                    //         return `￥ ${params.row.money_shangcheng}`
                    //     }
                    // },
                    {
                        title: '创建时间',
                        key: 'add_time',
                        align: "center",
                        render: (h, params) => {
                            if (params.row.add_time == null) {
                                return '暂无'
                            }
                            else {
                                return this.timeFormat(params.row.add_time)
                            }

                        }
                    },
                    {
                        title: '使用时间',
                        key: 'use_time',
                        align: "center",
                        render: (h, params) => {
                            if (params.row.use_time == null) {
                                return '暂无'
                            }
                            else {
                                return this.timeFormat(params.row.use_time)
                            }

                        }
                    },

                    {
                        title: '状态',
                        key: 'status',
                        align: "center",
                        render: (h, params) => {
                            if (params.row.status == 1) {
                                return '已使用'
                            }
                            else {
                                return '未使用'
                            }
                        }
                    },
                    {
                        title: '级别',
                        key: 'type',
                        align: "center",
                        render: (h, params) => {
                            if (params.row.type == 1) {
                                return "vip会员"
                            } else if (params.row.type == 2) {
                                return "金卡会员"
                            } else if (params.row.type == 3) {
                                return "钻卡会员"
                            } else if (params.row.type == 4) {
                                return "红钻会员"
                            } else {
                                return "皇冠会员 "
                            }
                        }
                    },
                    {
                        title: '被激活帐号',
                        key: 'use_username',
                        align: 'center',
                    },
                    {
                        title: '操作',
                        key: 'action',
                        align: 'center',
                        width: 120,
                        render: (h, params) => {
                            return h("div", [
                                h("ButtonGroup", {
                                    style: {
                                        marginTop: "5px"
                                    }
                                }, [

                                    // h("Button",{
                                    //     props:{
                                    //         type:"primary"
                                    //     },
                                    //     on:{
                                    //         click:()=>{
                                    //             this.uid = params.row.uid;
                                    //             this.get_myteam = true
                                    //         }
                                    //     }
                                    // },"查看下级"),
                                    // h("Button",{
                                    //     props:{
                                    //         type:"primary"
                                    //     },
                                    //     on:{
                                    //         click:()=>{
                                    //             if(params.row.tuandui==1){
                                    //                this.type = 2
                                    //             }else{
                                    //                 this.type = 1
                                    //             }
                                    //             this.id = params.row.userid
                                    //             this.modal2 = true
                                    //         }
                                    //     }
                                    // },(params.row.tuandui==1?"取消团队长":"成为团队长")),

                                    h("Button", {
                                        props: {
                                            type: "primary"
                                        },
                                        on: {
                                            click: () => {
                                                this.id = params.row.id;
                                                this.modal1 = true
                                            }
                                        }
                                    }, "删 除"),
                                ]),
                                h("ButtonGroup", {
                                    style: {
                                        margin: "5px 0px"
                                    }
                                }, [
                                    // h("Button",{
                                    //     props:{
                                    //         type:"primary"
                                    //     },
                                    //     on:{
                                    //         click:()=>{
                                    //             this.$router.push({name:'downList-nocache',query:{id:params.row.userid,name:params.row.loginname}})
                                    //         }
                                    //     }
                                    // },"下级列表"),
                                    // h("Button",{
                                    //     props:{
                                    //         type:"primary"
                                    //     },
                                    //     on:{
                                    //         click:()=>{
                                    //             this.$router.push({name:'down-agent-nocache',query:{id:params.row.userid,name:params.row.loginname}})
                                    //         }
                                    //     }
                                    // },"下级区代"),
                                    // h("Button",{
                                    //     props:{
                                    //         type:"primary"
                                    //     },
                                    //     on:{
                                    //         click:()=>{
                                    //             this.id = params.row.userid
                                    //             this.modal3 = true
                                    //         }
                                    //     }
                                    // },"升级金牌"),
                                    // h("Button",{
                                    //     props:{
                                    //         type:"primary"
                                    //     },
                                    //     on:{
                                    //         click:()=>{
                                    //             this.id = params.row.userid
                                    //             this.alertAgent()
                                    //         }
                                    //     }
                                    // },"设为代理"),
                                ])
                            ])
                        }
                    }
                    // {
                    //     title: '是否启用',
                    //     key: 'userstatus',
                    //     width:100,
                    //     align:"center",
                    //     render:(h,params)=>{
                    //         if(params.row.userstatus==1){
                    //             return h("Icon",
                    //                 {
                    //                     props:{
                    //                         type:"checkmark-round",
                    //                         color:"green",
                    //                     }
                    //                 }
                    //             )
                    //         }else{
                    //             return h("Icon",
                    //                 {
                    //                     props:{
                    //                         type:"close-round",
                    //                         color:"red",
                    //                     }
                    //                 }
                    //             )
                    //         }
                    //     }
                    // },

                ],
                data: [],
                total: 0,
                index: 1,
                modal1:false,
                page_con: 15,
                searchData: {

                    username: "",
                    phone: "",//
                    /*old_username:"",*/
                    num: "",
                    userStatus: "",
                    svip: "",
                    is_daili: "",
                    uid: '',
                },
                username: "",
                search_loading: false,
                id: "",
                type: 1,
                formValidate: {
                    level: "",
                    status: "",
                    money: '',
                },
                ruleValidate: {
                    level: [{required: true, message: '请选择激活状态', trigger: 'change'}],
                    ststus: [{required: true, message: '请选择会员等级', trigger: 'change'}],
                    money: [{required: true, message: '请输入资金金额', trigger: 'blur'}],
                },

            }
        },
        activated() {
            this.getOrderList()
        },
        mounted() {
        },
        methods: {
            getOrderList() {
                this.getJsonData("Card/index", {
                    username: this.searchData.username,
                    phone: this.searchData.phone,
                    /*old_username:this.searchData.old_username,*/
                    num: this.searchData.num,

                }, true)
                    .then((res) => {
                        this.data = res.card
                        this.total = parseInt(res.count)
                        this.search_loading = false
                    })
                    .catch((res) => {
                        this.search_loading = false
                    })
            },
            changePage(n) {
                this.index = n
                this.getOrderList()
            },
            changeTiao(num) {
                this.page_con = num
                this.index = 1
                this.getOrderList()
            },
            searchGetList() {
                this.search_loading = true
                this.index = 1
                this.getOrderList()
            },
            // 删除
            del(){
                this.modal_loading = true;
                this.getJsonData("Card/deleteCard",{id:this.id},true)
                    .then((res)=>{
                        this.getOrderList()
                        this.modal_loading = false;
                        this.modal1 = false;
                        this.$Message.success('删除成功');
                    }).catch((res)=>{
                    this.modal_loading = false;
                    this.modal1 = false;
                })
            },


            reset() {
                this.$refs.formValidateAgent.resetFields();
            }
        },
    }
</script>
<style lang="less">
    @import "pointcard-list";
</style>